home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 14305 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  51 lines

  1. Path: news.informatik.uni-muenchen.de!usenet
  2. From: Kurt Watzka <watzka@stat.uni-muenchen.de>
  3. Newsgroups: cs.forum,cuhk.se.3420,comp.lang.c
  4. Subject: Re: Help: a very segmentation fault!
  5. Date: Sat, 13 Apr 1996 02:50:01 +0200
  6. Organization: Institut fⁿr Statistik
  7. Message-ID: <316EFA39.2A6D@stat.uni-muenchen.de>
  8. References: <4ki7gu$bgc@eng_ser1.erg.cuhk.hk> <4kinqm$hnt@eng_ser1.erg.cuhk.hk>
  9. NNTP-Posting-Host: pc4.stat.uni-muenchen.de
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (WinNT; I)
  14.  
  15. Fan.. ... ... wrote:
  16. > I'm a good man (mfchan@cs.cuhk.hk) wrote:
  17. > > This is really the most strange thing I come across in C programming.
  18. > > main()
  19. > > {
  20. > >    char block[82];
  21. > >    fp2 = fopen("fool", "r+b");
  22.  
  23. If that file does not exist or cannot be accesse for both reading and writing,
  24. or if something strange happens to the stdio library, fopen() can fail. Using
  25. a NULL pointer returned from fopen() in calls to other functions that expect 
  26. a FILE pointer might lead to the observed behaviour.
  27.  
  28. > >    writeblock(fp2, 0, OVERFILE, block);
  29.  
  30. We cannot say much without knowing something about writeblock(). I assume that
  31. it does something similar to
  32.  
  33.    fwrite(block, sizeof block, 1, fp);
  34.  
  35.  
  36. > > }
  37. > > Need your help. Million Thks!
  38. > I've tried the program...  That's okay... except some syntax error...
  39. > One more thing...  What is your platform??  There's no "r+b" mode for
  40. > fopen on unix systems...  Default mode is binary for all files.
  41.  
  42. There _is_ a "r+b" mode in ANSI C. Whether it does something different from
  43. "w+" is up to the implementation.
  44.  
  45. Kurt
  46.